package com.zhuss.core.orign;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhuss.bean.bo.core.orign.CreateOrignBo;
import com.zhuss.bean.bo.core.orign.DeleteOrignBo;
import com.zhuss.bean.bo.core.orign.UpdateOrignBo;
import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.AabException;

/**
 * orign操作service（基本操作）
 * @author zhushanshuo
 * @Date 2020-02-20 11:58
 *
 */
@Component("orignOperateService")
public class OrignOperateService implements OperateService<Void, Object> {
	
	@Autowired
	@Qualifier("orignCreate")
	private Processor<Object, CreateOrignBo> orignCreate;
	
	@Autowired
	@Qualifier("orignUpdate")
	private Processor<Object, UpdateOrignBo> orignUpdate;
	
	@Autowired
	@Qualifier("orignDelete")
	private Processor<Object, DeleteOrignBo> orignDelete;
	
	/**
	 * 创建
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
	public Void create(Object param) throws AabException {
		
		CreateOrignBo bo = (CreateOrignBo) param;
		
		orignCreate.process(bo);
		
		return null;
	}
    
	/**
	 * 修改
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object param) throws AabException {
    	
		UpdateOrignBo bo = (UpdateOrignBo) param;
		
		orignUpdate.process(bo);
		
    	return null;
    }
	
	/**
	 * 删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Void delete(Object param) throws AabException {
		
		DeleteOrignBo bo = (DeleteOrignBo) param;
		
		orignDelete.process(bo);
		
		return null;
	}
	
}

